package com.rerijaapps.regalitosara;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
import android.media.FaceDetector;
import android.media.FaceDetector.Face;
import android.util.AttributeSet;
import android.widget.ImageView;

public class MyPhoto extends ImageView 
{

	public Bitmap myBitmap;
	public FaceDetector.Face[] detectedFaces;
	private float eyeDistance;
	
	public MyPhoto( Context context )
	{
		super( context, null );

	}
	
	public MyPhoto( Context context, AttributeSet attrs )
	{
		super( context, attrs );
	}

	@Override
	protected void onDraw( Canvas canvas )
	{
		canvas.drawBitmap( myBitmap, 0, 0, null );
		Paint myPaint = new Paint();
        myPaint.setColor( Color.GREEN );
        myPaint.setStyle( Paint.Style.STROKE ); 
        myPaint.setStrokeWidth( 3 );

        Face face = detectedFaces[0];
    	PointF midPoint = new PointF();
    	face.getMidPoint( midPoint );
    	
    	eyeDistance = face.eyesDistance();
    	
    	canvas.drawRect( midPoint.x - eyeDistance, midPoint.y - eyeDistance, midPoint.x + eyeDistance, midPoint.y + eyeDistance, myPaint );
	}
	
	

}
